"""
@Project:p8_syl_flask
@File:tasks.py
@Author:郑凯乐
@Date:19:30
"""
# 此处定义任务
import traceback
import logging
from celery_tasks import celery_app
from ronglian_sms_sdk import SmsSDK


accId = '8aaf07087f77bf96017fddc0c8423348'
accToken = 'f29cf86c06ce4199a17ee7b4f1a5ba75'
appId = '8aaf07087f77bf96017fddc0c922334f'

# 任务的名字
@celery_app.task
def phone_code(mobile, code):
    logging.info('phone_code:{}'.format(locals()))
    resp = 0
    try:
        sdk = SmsSDK(accId, accToken, appId)
        datas = (code, '5')
        resp = sdk.sendMessage('1', mobile, datas)
        print("发送的结果>>>", resp)
    except:
        error = traceback.format_exc()
        logging.error('phone_code error:{}'.format(error))
    return resp
